package com.henu.rescue.service.impl;

import com.henu.rescue.entity.Accident;
import com.henu.rescue.entity.Organization;
import com.henu.rescue.entity.VO.*;
import com.henu.rescue.mapper.AccidentMapper;
import com.henu.rescue.service.AccidentService;
import com.henu.rescue.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


@Service
public class AccidentServiceImpl implements AccidentService {

    @Autowired
    private AccidentMapper accidentMapper;

    @Override
    public Integer addAccident(Accident accident) {
        return accidentMapper.add(accident);
    }

    @Override
    public Page<AccidentVO> selectOAccInfoByPage(Page<AccidentVO> page) {
        List<AccidentVO> accList = accidentMapper.selectAccInfoByPage(page);
        page.setList(accList);
        //查询总数
        int totalCount =accidentMapper.getCountByPage(page);
        page.setTotalCount(totalCount);
        return page;
    }

    @Override
    public Integer delAccident(Integer accId) {
        return accidentMapper.del(accId);
    }

    @Override
    public Integer delAccidentLogic(Integer accId) {
        return accidentMapper.delLogic(accId);
    }

    @Override
    public Accident selectById(Integer accId) {
        return accidentMapper.selectById(accId);
    }

    @Override
    public Integer distribute(Integer accId, String orderId) {
        return accidentMapper.distribute(accId,orderId);
    }

    @Override
    public Page selectNoDistributeByPage(Page<Accident> page) {
        List accList = accidentMapper.selectNoDistributeByPage(page);
        page.setList(accList);
        //查询总数
        int totalCount =accidentMapper.getNoDistributeCountByPage(page);
        page.setTotalCount(totalCount);
        return page;
    }

    @Override
    public List<AccidentMapVO> selectAccidentMapVO() {
        return accidentMapper.selectAccidentMapVO();
    }

    @Override
    public List<AccidentCause> selectAccidentCause() {
        return accidentMapper.selectAccidentCause();
    }

    @Override
    public List<AccTimeAndCount> selectAccTime(Date lowTime, Date highTime) {
        return accidentMapper.selectAccTime(lowTime,highTime);
    }

    @Override
    public List<AccidentYearVO> selectAccidentByYear(Integer year) {
        return accidentMapper.selectAccidentByYear(year);
    }

    @Override
    public List<AccidentAllYearVO> selectAllYear() {
        return accidentMapper.selectAllYear();
    }


}
